const gulp = require('gulp')
const swig = require("gulp-swig");
const sass = require("gulp-sass")
const { src, dest, parallel } = require('gulp');
const babel = require('gulp-babel')
const imagemin = require('gulp-imagemin')
const del = require("del")

const html = done =>{
    return src('src/*.html')
    .pipe(swig({data:{
        title:'这就是标题',
        pkg:{
            name:'测试'
        }
    }}))
    .pipe(dest('dist'))
}

const style = done=>{
    return src('src/assets/styles/*.scss',{base:'src'})
    .pipe(sass({}))
    .pipe(dest('dist'))
}

const script = done => {
    return src('src/assets/scripts/*.js',{base:'src'})
    .pipe(babel())
    .pipe(dest("dist"))
}

const image = done => {
    return src("src/assets/images/**",{base:'src'})
    .pipe(imagemin())
    .pipe(dest('dist'))
}

const font = done => {
    return src("src/assets/fonts/**",{base:'src'})
    .pipe(imagemin())
    .pipe(dest('dist'))
}

const public = done =>{
    return src('public/**',{base:'public'})
    .pipe(dest('dist'))
}

const clean = done => {
    return del(['dist'])
}

const compile = parallel(html,style,script,image,font,public)

exports.default = done => {
    
    done()
}
module.exports = {
    clean,
    compile
}